# -*- coding: iso-8859-1 -*-
#
#    This is part of Malvinas Argentinas Messenger
#
#    Malvinas Argentinas Messenger is free software; you can redistribute
#    it and/or modify it under the terms of the GNU General Public License
#    as published by the Free Software Foundation; either version 2 of the
#    License, or (at your option) any later version.
#
#    Malvinas Argentinas Messenger is distributed in the hope that it will be
#    useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Malvinas Argentinas Messenger; if not, write to the Free
#    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
#    MA  02110-1301  USA

import msgWin, msg, button
import gettext
_ = gettext.gettext

def handleOption(ui, i):
	# Distinto de flechas o TAB
	if i <> -2:
		ui.options_win = 0
		# F4
		if i <> -1:
			ui.options_index = -1
			ui.options_list = 0
		# Elegi primera opcion
		if not i:
			ui.printMsg('\n%s ' % ui.winOpt2.ctime, ui.COLORS.WHITE)
			ui.printMsg('Message to ', ui.COLORS.WHITE_R)
			ui.printMsg('(%s)' % ui.winOpt2.email, ui.COLORS.GREEN_R)
			ui.printMsg(' %s.' %
			_('added to offline messages list'), ui.COLORS.WHITE_R)
			ui.mam.addFlnMsg(ui.winOpt2.email, ui.winOpt2.msgToSend)
			ui.mam.dumpFlnMsgslist('.offline')
			ui.padArray.refresh(_('EVENTS'))
		del ui.winOpt2
		ui.refreshScr()

# We create the MsgWin
def showWin(mam):
		show_groups = int(mam.config['show_groups'])
		if show_groups:
			nick = mam.contactListManager.gList.grupos[mam.contactListManager.default_group].passports.passports[mam.contactListManager.default_user].nick
			passport = mam.contactListManager.gList.grupos[mam.contactListManager.default_group].passports.passports[mam.contactListManager.default_user].name
		else:
			passport = mam.contactListManager.pList.passports[mam.contactListManager.default_user].name
			nick = mam.contactListManager.pList.passports[mam.contactListManager.default_user].nick
		msgWin.MsgWin(mam, _('OFFLINE MESSAGE'), \
		[msg.Msg(_("Cannot send message to .."), '', 1), \
		msg.Msg(nick, mam.ui.COLORS.OPTIONS_WIN4, 1), \
		msg.Msg("(%s)" % passport, mam.ui.COLORS.OPTIONS_WIN4, 1), \
		msg.Msg(_("Do you want to leave him / her an offline message"), '', 0), \
		msg.Msg(" ?", '', 1)], \
		[button.Button(_("YES"), 0), button.Button(_("NO"), 1)], mam.ui.maxX * 5 / 7)
